fix(bedrock_mantle): stop dropping the web_search tool on /v1/responses - #35987
Conversation
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
Greptile SummaryThe PR allows Bedrock Mantle Responses requests to retain the
Confidence Score: 5/5The PR appears safe to merge. No blocking failure remains.
|
| Filename | Overview |
|---|---|
| litellm/llms/bedrock_mantle/responses/transformation.py | Extends the Mantle Responses tool allowlist so web-search requests reach the provider unchanged. |
| model_prices_and_context_window.json | Advertises web-search support for the five intended Bedrock Mantle GPT models. |
| litellm/model_prices_and_context_window_backup.json | Keeps backup model capability metadata synchronized with the primary cost map. |
| tests/test_litellm/llms/bedrock_mantle/test_bedrock_mantle_responses_transformation.py | Covers top-level and hoisted web-search preservation, option retention, capability metadata, and unsupported-tool filtering. |
Reviews (2): Last reviewed commit: "test(bedrock_mantle): capture the drop w..." | Re-trigger Greptile
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
c50debd to
26805f7
Compare
|
@mateo-berri curious on any ETA on when this PR will be merged? |
^ My team wants to use Litellm but we are waiting for this change |
…itellm_bedrock_mantle_web_search
… patching the logger
|
bugbot run |
There was a problem hiding this comment.
✅ Bugbot reviewed your changes and found no new issues!
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit 8713ba8. Configure here.
7d6781f
into
litellm_internal_staging
TLDR
Problem this solves:
/v1/responsesbedrock_mantlesilently dropped theweb_searchtoolHow it solves it:
web_searchthrough the Mantle tool filterUser Flow
Before: a developer who sends Bedrock's
web_searchtool through the gateway gets a 200 with an ungrounded answer and no citations"model": "bedrock-gpt-5-6-sol", a question about a recent event, and"tools": [{"type": "web_search", "external_web_access": false}]"tools": [], and itsoutputholds onlyreasoningandmessageitems, noweb_search_callurl_citationannotations"web_search_options": {}(noannotationson the message) and on POST https://litellm-domain/v1/messages with theweb_search_20250305tool (an ungrounded text block)After: the same request runs the searches on Bedrock and comes back grounded with citations
web_searchtool"tools": [{"type": "web_search", ...}], andoutputholds twoweb_search_callitems (asearchand anopen_page) ahead of themessageurl_citationannotations pointing at aws.amazon.com"web_search_options": {}now returnsurl_citationentries underannotations, and POST https://litellm-domain/v1/messages with theweb_search_20250305tool returns a grounded text block with the source link inlineRelevant issues
Fixes #36649
Linear ticket
Resolves LIT-5224
Pre-Submission checklist
Please complete all items before asking a LiteLLM maintainer to review your PR
uv run pytest tests/test_litellm/llms/bedrock_mantle/test_bedrock_mantle_responses_transformation.py -v. Leave the suites (make test-unit-*,make test-unit) to CI: it finishes in ~15 minutes where a laptop takes an hour or more@greptileaito re-request a review after pushing changes)Delays in PR merge?
If you're seeing a delay in your PR being merged, ping the LiteLLM Team on Slack (#pr-review).
Screenshots / Proof of Fix
Two live proxies against real Bedrock Mantle in us-east-1, each booted with
--num_workers 2on a random free port from its own worktree: Before at the merge base on port 22948, After at this PR's tip on port 27930. Same config, same payloads, same question, only the checked out commit differs.AWS_BEARER_TOKEN_BEDROCKcomes from the environmentPayloads, all asking
What did AWS announce about Web Search on Amazon Bedrock on August 4 2026?:Before (4990f06)
/v1/responses, non-streaming
post /v1/responses responses_nonstream; jq -c '{types: [.output[].type], tools, citations: [.output[] | select(.type=="message") | .content[].annotations[]? | .url]}' responses_nonstream.out; grep -i '^x-litellm-response-cost:' responses_nonstream.headers/v1/responses, streaming
post /v1/responses responses_stream; grep '^data: ' responses_stream.out | sed 's/^data: //' | jq -r .type | sort | uniq -c | sort -rnweb_search_callevents at all/v1/chat/completions with web_search_options
post /v1/chat/completions chat_web_search_options; jq -c '{finish_reason: .choices[0].finish_reason, annotations: .choices[0].message.annotations, content: .choices[0].message.content[0:120]}' chat_web_search_options.out; grep -i '^x-litellm-response-cost:' chat_web_search_options.headers/v1/messages with the web_search tool
post /v1/messages messages_web_search; jq -c '{types: [.content[].type], stop_reason, text: .content[0].text[0:120]}' messages_web_search.out; grep -i '^x-litellm-response-cost:' messages_web_search.headers/v1/responses on a Mantle model without Web Search (gpt-oss-120b)
post /v1/responses responses_gptoss; jq -c '{types: [.output[].type], tools, answer: ([.output[] | select(.type=="message") | .content[].text] | join(" ") | .[0:120])}' responses_gptoss.outAfter (8713ba8)
/v1/responses, non-streaming
post /v1/responses responses_nonstream; jq -c '{types: [.output[].type], tools, citations: [.output[] | select(.type=="message") | .content[].annotations[]? | .url]}' responses_nonstream.out; grep -i '^x-litellm-response-cost:' responses_nonstream.headers/v1/responses, streaming
post /v1/responses responses_stream; grep '^data: ' responses_stream.out | sed 's/^data: //' | jq -r .type | sort | uniq -c | sort -rnresponse.web_search_call.*events and the citations arrive asannotation.addedevents/v1/chat/completions with web_search_options
post /v1/chat/completions chat_web_search_options; jq -c '{finish_reason: .choices[0].finish_reason, annotations: [.choices[0].message.annotations[] | .url], content: .choices[0].message.content[0:120]}' chat_web_search_options.out; grep -i '^x-litellm-response-cost:' chat_web_search_options.headersurl_citationannotations, grounded answer/v1/messages with the web_search tool
post /v1/messages messages_web_search; jq -c '{types: [.content[].type], stop_reason, text: .content[0].text[0:120]}' messages_web_search.out; grep -i '^x-litellm-response-cost:' messages_web_search.headers/v1/responses on a Mantle model without Web Search (gpt-oss-120b)
post /v1/responses responses_gptoss; jq -c '{types: [.output[].type], tools, answer: ([.output[] | select(.type=="message") | .content[].text] | join(" ") | .[0:120])}' responses_gptoss.outObservations from the run, none caused by this PR:
x-litellm-response-cost-tool-usagestays 0 (left alone, LIT-6870)/v1/messagesreturns citations inline, noweb_search_tool_resultblocks (left alone)gpt-5.6-cyber,grok-4.6(pre-existing)Type
🐛 Bug Fix
Changes
BedrockMantleResponsesAPIConfigfilters the Responsestoolsarray against an allowlist of tool types Mantle accepts, andweb_searchpredates AWS shipping it, somap_openai_paramsdropped it before the request went out. Web Search on Amazon Bedrock went GA on 2026-08-04 as a server-side built-in tool on the OpenAI Responses path for GPT-5.4, GPT-5.5 and GPT-5.6 Sol/Terra/Luna, so the tool now stays in the payload with itsexternal_web_accessfield untouched, both for a top-leveltoolsentry and for one hoisted out of a Codexadditional_toolsinput itemThe five GPT entries in the cost map also gain
supports_web_search: truesolitellm.supports_web_search()and the router's web-search-aware filtering see the capability. Nothing else in the Mantle lineup gets the flag, since AWS scopes Web Search to those modelsFour existing tests used
web_searchas their stand-in for an unsupported tool type, so they now usefile_search, which Mantle really does reject and which this config already declares unsupported. The test that pinsweb_searchout of the drop warning reads the warning back throughcaploginstead of patching the loggerCaveats (if any)
Medium
x-litellm-response-cost-tool-usagestays 0 on every leg aboveLow
web_searchrequest to the gpt-oss onemodel_info: {supports_web_search: false}on that deployment, the router honors itlocal_testing_part1andlocal_testing_part2are red on tests this PR never touchescohere.command-r-plus-v1:0tests hit Bedrock's end-of-life error, unrelated to MantleFinal Attestation
Link to Devin session: https://app.devin.ai/sessions/56ac33bc3eb44a15a96c7022683ff161
Requested by: @mateo-berri